package com.msb.mall.product.config;

import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * TODO： 这个目前在gateway使用了，但是当前微服务使用了 security
 *  如果删除，会导致调用401，后面再看看能否做成 全局控制，不用重复写入
 *
 * @author xulei
 * @date 2024/4/27 0:28
 */
@EnableWebSecurity
@Configuration(proxyBeanMethods = false)
public class MySecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.requestMatcher(EndpointRequest.toAnyEndpoint())
                .authorizeRequests((requests -> requests.anyRequest().permitAll()));
    }
}
